<%= form_for([@post, @post.comments.new])  do |f|%>
  <% if flash[:error] %>
	<div id="error_explanation" class='error_message'>
    	<p><%=I18n.t('error_msg')%></p>
    	<%=image_tag('dialog-close.png', 
    								:size => '16x16', 
    								:class => 'close-msg',
    								:alt => I18n.t('close'), 
    								:title => I18n.t('close'))%>
  </div>
	<%end%>
  <p class='cmm-r'>        
		<label for="name" class='lfield'>
      <small>Tên <span class='starf-rq'>*</span></small>
    </label>
    <%= f.text_field :name, {:tabindex=>1, :size=>22, :class=>'required'}%>
  </p>
  <p class='cmm-r'>        
		<label for="email" class='lfield'>
      <small>Email <span class='starf-rq'>*</span></small>
    </label>
    <%= f.text_field :email, {:tabindex=>2, :size=>22, :class=>'required'}%>    
  </p>
  <p class='cmm-r'>        
    <label for="website" class='lfield'>
      <small>Website</small>
    </label>
    <%= f.text_field :website, {:tabindex=>3, :size=>22}%>
  </p>
  <p class='cmm-r'>        
    <label>
      <small>Lời bình <span class='starf-rq'>*</span></small>
    </label><br/>
    <%= f.text_area :content, {:tabindex=>4, :width=>"85%", :rows=>"10", :class => 'mceEditorBasic'}%>
  </p>
  <p>
    <%= f.submit 'Gửi bình luận', :id => 'submit-comment' %>
  </p>
<%end%>

<%=content_for :js do %>
<script type='text/javascript'>
	$(document).ready(function(){
		var flagSubmit = false;
		$('#submit-comment').click(function(){
			var content = tinyMCE.get('comment_content').getContent(); 
			if(content == "" || content == null){				
				var parent = $('#comment_content').parent()[0];
				$('> .err', parent).remove();
				$(parent).append('<label class="err">' + $.validator.messages.required + '</label>');
				flagSubmit = false; 					
			}else{
				var parent = $('#comment_content').parent()[0];
				$('> .err', parent).remove();
				flagSubmit = true; 
			}
			$("#new_comment").submit();
		});
		//validate
		$("#new_comment").validate();			
		$("#new_comment").submit(function(){
			return flagSubmit;
		});
	});
</script>
<%end%>
